package com.itheima.d4_jdk8_time;

import com.sun.tools.javac.Main;

import java.time.LocalDate;

public class Test1_LocalDate {
    public static void main(String[] args) {
        //获取本地日期
        LocalDate ld = LocalDate.now();
        System.out.println(ld);

        //获取信息对象中的日期
        int year = ld.getYear();
        int month = ld.getMonthValue();
        int dayOfMonth = ld.getDayOfMonth();
        System.out.println(year + "年" + month + "月" + dayOfMonth + "日");

        //直接修改日期
        LocalDate ld2 = ld.withYear(1999);
        System.out.println(ld2);

        //把日期往后推几天
        LocalDate ld3 = ld.plusDays(10);
        System.out.println(ld3);

        //把日期往前推几天
        LocalDate ld4 = ld.minusDays(10);
        System.out.println(ld4);

        //判断两个日期是否相等
        LocalDate ld5 = LocalDate.of(2023, 1, 1);
        System.out.println(ld.equals(ld5));
        System.out.println("-------");

        //LocalTime获取当前时间
        LocalDate ld6 = LocalDate.now();
        System.out.println(ld6);

        //LocalDateTime获取当前时间
        LocalDate ld7 = LocalDate.now();
        System.out.println(ld7);


    }
}
